package de.snom;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.jface.fieldassist.ContentProposal;
import org.eclipse.jface.fieldassist.IContentProposal;
import org.eclipse.jface.fieldassist.IContentProposalProvider;


public class MyContentProposalProvider implements IContentProposalProvider {

	@Override
	public IContentProposal[] getProposals(String contents, int position) {
		if (!contents.matches("[\\+|0-9| ]*")) {
			List<Contact> contacts = AdressBook.get().getContactsForString(
					contents);
			ArrayList<ContentProposal> contentProposals = new ArrayList<ContentProposal>();
			for (Contact contact : contacts) {

				for (String number : contact.getPhoneNumbers()) {

					contentProposals.add(new ContentProposal(contact
							.getFullName() + "  --  " + number));
				}

			}
			return contentProposals
					.toArray(new IContentProposal[contentProposals.size()]);
		}
		return new IContentProposal[0];
	}

}
